import React from 'react';

function HOC (Component:any){
  const didMount = Component.prototype.componentDidMount;
  Component.prototype.componentDidMount = function(){
    console.log('劫持生命周期：componentDidMount')
    didMount.call(this)
  }

  return class Index extends React.Component{
    render(){
      return <Component {...this.props}  />
    }
  }
}
class Index extends React.Component{

  componentDidMount(){
    console.log('---componentDidMount---')
  }

  render(){
    return <div>大家好，我是小杜杜</div>
  }
}

export default HOC(Index);
